<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('返利列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>订单编号：</label>
                            <input type="text" name="orderNum"/>
                        </li>
                        <li>
                            <label>会员号：</label>
                            <input type="text" name="phoneNum"/>
                        </li>
                        <li class="select-time">
                            <label>下单时间：</label>
                            <input type="text" class="time-input"  placeholder="开始时间"  name="params[startTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input"  placeholder="结束时间" name="params[endTime]" />
                        </li>
                        <li shiro:hasPermission="streamShop:streamShop:consumeCompany">
                            <label>消费单位：</label>
                            <input type="text" name="consumeCompany"/>
                        </li>
                        <li>
                            <label>收益单位：</label>
                            <input type="text" name="belongCompany"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="mySearch()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="myReset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--  <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="streamShop:streamShop:add">
                  <i class="fa fa-plus"></i> 添加
              </a>
              <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="streamShop:streamShop:edit">
                  <i class="fa fa-edit"></i> 修改
              </a>
              <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="streamShop:streamShop:remove">
                  <i class="fa fa-remove"></i> 删除
              </a>
              <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="streamShop:streamShop:export">
                  <i class="fa fa-download"></i> 导出
              </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('streamShop:streamShop:edit')}]];
    var removeFlag = [[${@permission.hasPermi('streamShop:streamShop:remove')}]];

    var showFlag = [[${@permission.hasPermi('streamShop:streamShop:consumeCompany')}]];
    var prefix = ctx + "streamShop/streamShop";
    var data;
    $(function () {
        toSum();
        var options = {
            url: prefix + "/selectReturnList",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            showSearch: false,
            showRefresh: false,
            showColumns: false,
            showToggle: false,
            showFooter: true,
            modalName: "商家流水",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'null',
                    visible: false
                },
                {
                    field: 'orderNum',
                    title: '订单编号',
                    footerFormatter: function () {
                        return '汇总'
                    }
                },
                {
                    field: 'phoneNum',
                    title: '会员号'
                },
                {
                    field: 'streamMoney',
                    title: '返利金额',
                    footerFormatter: function (row) {
                        return data;
                    }
                },
                {
                    field: 'consumeCompany',
                    title: '消费单位',
                    visible: showFlag == "hidden"? false : true,
                },
                {
                    field: 'belongCompany',
                    title: '收益单位'
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                }]
        };
        $.table.init(options);
    });

    /*搜索*/
    function mySearch() {
        toSum()
        $.table.search()
    }

    /*重置*/
    function myReset() {
        $.form.reset()
        toSum()
    }
    function toSum() {
        $.ajax({
            type: "POST",
            cache: false,
            data: $('#formId').serialize(),
            async: false,
            url: prefix + "/selectReturnList",
            success: function (res) {
                data = res.detailSum;
            }
        });
    }
</script>
</body>
</html>